﻿


import Request from '../../base/request.js?t=202511041006'
import Storage from '../../base/storage.js?t=202511041006'
import { imageBaseUrl, isImageFile, dealTime, getMonthList, queryURLParams, downloadfun, getBrowserInfo,dealmark } from "../../base/utils.js?t=202511041006"

const Composition = (proxy) => {
    const data = reactive({

        pdfOpen: false,
        pdfurl: "",

        proxy: "",
        type: "",
        fileOpen: false,
        autoSaveParams: {
            countOpen: false,
            mainTimer: null,
            countdownTimer: null,
            countdown: 10,
            ocountdown: 10,
            size: 26,
            setIntervalTime: 5 * 1000 * 60
        },
        subform: {

        },
        mid:"",
        listInfo: {
            Title: null,
            UpdateTime: null,
            UserName: null,
            UserNo:null,
            UserNo:null,
            Manager: null,
            DepartmentName:null
        },
        totalAmount:0,
        dict: {
            0:'通用表考评',
            1: '重点工作考评',
            2: '现场检查考评',
        },
        ScoreRate:1,
        urlParams: {},
        s3Form: {
            TeamId: "",
            StartTime: "",
            EndTime: "",
            DepartmentId: "",
            Factor: "",
        },
        s4Form: {
            TeamId: "",
            StartTime: "",
            EndTime: "",
            DepartmentId: "",
            Factor: "",
        },
        checkGroup: [],
        memberGroup: [],

        cmemberGroup1: [],
        cmemberGroup2: [],
        checkFrom: {
            userName: "",
            userId: "",
            checkDate: "",
            advice: ""
        },
        previewShow: false,
        imgUrl: "",
        form: {
            plan: null,
            year: "",
            person: "",
            duty: "",
            subdept: ""

        },
        totala: 0,
        totals: 0,
        TotalScore: 0,
        ti:0,
        i: 0,
        is: 0,
        iss: 0,
        planList: [],

  
        lists: [

        ],

        activeKey: [0, 1,2],

        messageTest: "",

        formState: {
            dept: "",
            name: "",
            job: "",
            role: "",
            tel: "",
        },

        chooseFiles: [],

        deptList: [
       
        ],

        monthList: [
      
        ],

        pagination: {
            total: 0,
            loading: true,
            current: 1,
            pageSize: 10,
            showTotal: total => `总共 ${total} 项`,
            defaultPageSize: 10,
            // pageSizeOptions: ['5', '10', '15', '20'], // 可不设置使用默认
            showSizeChanger: true, // 是否显示pagesize选择
            showQuickJumper: false, // 是否显示跳转窗
        },

        uploadLock:false,
        memberList: [],

        chooseMember: {},
        
        logList: [],
        rules: {
            dept: [{ required: true, message: '请选择部门', trigger: 'change' }],
            name: [{ required: true, message: '请选择成员', trigger: 'change' }],

        },
        opType: "",
        confirmShow: false,
        delId: "",

        open: false,

        queryParams: {
            role: "",
            dept: "",
        },
        statusList: [
            { name: '组长', code: '0' },
            { name: '组员', code: '1' },

        ],


        columns: [
            {
                title: '序号',
                dataIndex: 'index',
                key: 'index',
                align: 'center',
                width: 80,
                customRender: ({ index}) => {
                    return index + 1
                },
            },
            {
                title: '应用模块',
                dataIndex: 'a',
                key: 'a',
                align: 'center',
                customRender: function ({ text, record, index, column }) {
                    let linkBtn = h(antd.Button, { type: 'link' }, () => text)


                    return linkBtn
                }


            },
            {
                title: '考评扣分',
                dataIndex: 'b',
                key: 'b',
                align: 'center',
                customRender: function ({ text, record, index, column }) {

                    let numberInput = h(antd.InputNumber, { style: 'width:140px', placeholder: "请输入考评扣分", min: 0, max: 100 }, () => text)


                    return numberInput
                }
            },
            {
                title: '扣分缘由',
                dataIndex: 'c',
                key: 'c',
                align: 'center',
                customRender: function ({ text, record, index, column }) {
                    let textArea = h(antd.Textarea, { placeholder: "请输入扣分缘由", autoSize: { minRows: 2, maxRows: 5 } }, () => text)
                    return textArea
                }
            },

        ],
        dataSource: [],
        fileList: [],
        itemRender: (data) => {



            let uid = data.file.uid
            const text = h('div', { style: 'cursor:pointer;margin-left:10px' }, data.file.name)
            const previewBtn = h('img', { style: 'cursor:pointer;margin:0 4px;', onclick: () => { methods.btnPreview(uid, 1) }, src: "../Bussiness/img/svg/preview.svg", width: 20, height: 22 }, '预览')
            const downloadBtn = h('img', { style: 'cursor:pointer;margin:0 4px;', onclick: () => { methods.btnDownLoad(uid, 1) }, src: "../Bussiness/img/svg/download.svg", width: 20, height: 22 }, '下载')
            //const deleteBtn = h('img', { style: 'cursor:pointer;margin:0 4px;', onclick: () => { methods.btnDelete(uid, 1) }, src: "../Bussiness/img/svg/delete.svg", width: 18, height: 22 }, '删除')
            var btns = ""

            if (isImageFile(data.file.url)) {
                btns = h('div', { style: "display:flex;" }, [
                    previewBtn,
                    downloadBtn,
                    //deleteBtn
                ])
            } else {
                btns = h('div', { style: "display:flex;" }, [
                    downloadBtn,
                    //deleteBtn
                ])
            }

            return h('div', { style: 'margin-top:10px; width:100%;display:flex;justify-content:space-between' }, [
                text, btns
            ])

        },
    })
    let params = toRefs(data)

    const methods = {
        filterOption: (val, type) => {
            return `${type.value}`.includes(`${val || ''}`)
        },
        handleChange: (info, ee) => {
            if (!params.uploadLock.value) {


                params.uploadLock.value = true
                let formData = new FormData();
                formData.append('nfile', info.file.originFileObj)
                formData.append('uid', info.file.originFileObj.uid)
                Request({
                    url: "/download/uploadfile?Path=Performance",
                    method: 'post',
                    data: formData
                }).then(res => {
                    let item = params.lists.value[params.ti.value].NodeList
                    [params.i.value].NodeList[params.is.value].NodeList
                    [params.iss.value].ResultItemFileList.find(e => e.uid == res.Data[0].uid)
                    item.url = imageBaseUrl + res.Data[0].FilePath.split('../..')[1]
                    item.FileId = res.Data[0].FileId
                    item.FileName = res.Data[0].FileName

                    delete item.response

                    if (!params.lists.value[params.ti.value].NodeList
                    [params.i.value].NodeList[params.is.value].NodeList
                    [params.iss.value].uploadList) {
                        params.lists.value[params.ti.value].NodeList
                        [params.i.value].NodeList[params.is.value].NodeList
                        [params.iss.value].uploadList = []
                    }
                    params.lists.value[params.ti.value].NodeList
                    [params.i.value].NodeList[params.is.value].NodeList
                    [params.iss.value].uploadList.push(item)


                    params.uploadLock.value = false
                    if (ee) {
                        methods.tChange(ee)
                    }
                })
            }




        },

 
        setVisible: (value) => {
            params.previewShow.value = value;
        },
        btnPreview: (e, type) => {
            if (type) {

                let item = params.fileList.value.find(es => es.uid == e)
                item.url = item.FilePath || item.url
                if (item.url.indexOf('.pdf') != -1) {
                    params.pdfurl.value = item.url
                    params.pdfOpen.value = true
                } else {
                    params.imgUrl.value = item.url

                    methods.setVisible(true)
                }
                return
            }

            let item = params.chooseFiles.value.find(es => es.uid == e)
            item.url = item.FilePath || item.url
            if (item.url.indexOf('.pdf') != -1) {
                params.pdfurl.value = item.url
                params.pdfOpen.value = true
            } else {
                params.imgUrl.value = item.url

                methods.setVisible(true)
            }
        },

        btnDownLoad: (e, type) => {
            if (type) {

                let item = params.chooseFiles.value.find(es => es.uid == e)


                item.url = item.FilePath || item.url

                const { name, url } = item

                downloadfun(name, url)
                return
            }

            let item = params.chooseFiles.value.find(es => es.uid == e)


            const { name, url, FilePath } = item
 
            downloadfun(name, url || FilePath)

        },
        btnDelete: (e, type) => {
            if (type) {
                params.chooseFiles.value = params.chooseFiles.value.filter(es => es.uid != e)
                params.lists.value[params.ti.value].NodeList
                [params.i.value].NodeList[params.is.value].NodeList
                [params.iss.value].ItemFileList = params.lists.value[params.ti.value].NodeList
                [params.i.value].NodeList[params.is.value].NodeList
                [params.iss.value].ItemFileList.filter(es => es.uid != e)
                return
            }

            params.lists.value[params.ti.value].NodeList
            [params.i.value].NodeList[params.is.value].NodeList
            [params.iss.value].ResultItemFileList = params.lists.value[params.ti.value].NodeList
            [params.i.value].NodeList[params.is.value].NodeList
            [params.iss.value].ResultItemFileList.filter(es => es.uid != e)

            params.lists.value[params.ti.value].NodeList
            [params.i.value].NodeList[params.is.value].NodeList
            [params.iss.value].uploadList = params.lists.value[params.ti.value].NodeList
            [params.i.value].NodeList[params.is.value].NodeList
            [params.iss.value].uploadList.filter(es => es.uid != e)

            params.chooseFiles.value = params.chooseFiles.value.filter(es => es.uid != e)
        },



        tChange: function (e) {

            if (e.ItemId) {
                methods.UpdateEvalutionUser(e.ItemId).then(res => {
                    let info = Storage.get('AccountInfo', true)
                    e.EvalutionName = `${info.UserName}(${info.UserNo})`
                })
            } else {
                let info = Storage.get('AccountInfo', true)
                e.EvalutionName = `${info.UserName}(${info.UserNo})`
            }

        },
        planChange: (e) => {

            Request({
                url: "/Performance/GetSelfTempleteByPlan",
                method: 'post',
                params: {
                    Id: e
                }

            }).then(res => {

                params.list.value = res.Data[0].NodeList
                params.TotalScore.value = res.Data[0].TotalScore

            })
        },
        handleFile: (i, is, iss, ess) => {
            params.fileOpen.value = true


            params.chooseFiles.value = ess.ItemFileList.map(e => {

                e.url = e.url ? e.url : imageBaseUrl + e.FilePath.split('../..')[1]
                e.FileId = e.FileId
                e.name = e.FileName
                e.isImage = isImageFile(e.url || e.FilePath)
                e.isDelete = false
                return e
            })


        },
        handleFile1: (ti, i, is, iss, ess) => {
            params.fileOpen.value = true

            params.chooseFiles.value = ess.ResultItemFileList.map(e => {
                return {
                    ...e,
                    FileId: e.FileId,
                    name: e.originFileObj ? e.name : e.FileName,
                    isImage: isImageFile(e.url || e.FilePath),
                    isDelete: params.urlParams.value.status != 4
                }
            })


        },

        cwtfbtn() {


            params.uploadLock.value = true
            html2canvas(document.querySelector("#c0")).then(async (canvas) => {
                console.log(canvas)

                // 将 canvas 转换为 Blob
                const blob = await new Promise((resolve, reject) => {
                    canvas.toBlob(resolve, 'image/png');
                });

                // 创建 FormData 对象
                const formData = new FormData();
                formData.append('file', blob, 'pdf.png');

                Request({
                    url: "/download/uploadfile?Path=toPdf",
                    method: 'post',
                    data: formData
                }).then(res => {
                    console.log(res, 'res')
                    params.uploadLock.value = false
                })
            });
        },

        uni: (arry) => {
            let list = new Set()
            for (let e of arry) {
                list.add(e)
            }

            return Array.from(list).filter(Boolean)
           
        },

        iichange: (i) => {

            let list = new Set()

            if (params.lists.value[i].NodeList) {
                for (let node of params.lists.value[i].NodeList) {

                    if (node.NodeList) {

                        for (let item of node.NodeList) {

                            if (item.NodeList) {
                                for (let ii of item.NodeList) {
                                    list.add(ii.EvalutionName)
                                }
                            }


                        }
                    }

                }
            }


            params.lists.value[i].nameList = Array.from(list).filter(Boolean)

        


            let f = params.lists.value[i].NodeList.map((e, i) => {
                let ff = {

                }
                if (e.CalcType == 0) {
                    if (e.NodeList) {
                        let zz = e.NodeList.map(es => {
                            if (es.NodeList) {
                                let res = es.NodeList.map(ess => {
                                    return ess.ResultScore ? ess.ResultScore : 0
                                })
                                return res.reduce((prev, cur, index, arr) => {
                                    return prev + cur
                                }, 0)
                            }
                        })
                        ff.sub = zz.reduce((prev, cur, index, arr) => {
                            return prev + cur
                        }, 0)
                    }
                } else {
                    if (e.NodeList) {
                        let zz = e.NodeList.map(es => {
                            if (es.NodeList) {
                                let res = es.NodeList.map(ess => {
                                    return ess.ResultScore ? ess.ResultScore : 0
                                })
                                return res.reduce((prev, cur, index, arr) => {
                                    return prev + cur
                                }, 0)
                            }
                        })
                        ff.add = zz.reduce((prev, cur, index, arr) => {
                            return prev + cur
                        }, 0)
                    }
                }

                return ff
            })



            params.lists.value[i].totala = 0
            params.lists.value[i].totals = 0
            params.lists.value[i].TotalScore = params.lists.value[i].TotalScore



            for (let e of f) {
                if (e.add) {
                    params.lists.value[i].totala += e.add
                } else if (e.sub) { params.lists.value[i].totals += e.sub }
            }

            let total = params.lists.value.reduce((acc, item) => acc + item.TotalScore, 0);



            params.totalAmount.value = params.lists.value.reduce((acc, item) => acc + Number(methods.Idealmark(item.TotalScore - (item.totals * params.ScoreRate.value - item.totala).toFixed(2), item.TotalScore)), 0);



            params.totalAmount.value = Number(Number(params.totalAmount.value / total * 100).toFixed(2))
 

        },
        ichange: (e, ee) => {

            if (ee) {


                methods.tChange(ee)
            }

            let f = params.lists.value[0].NodeList.map((e, i) => {
                let ff = {

                }
                if (e.CalcType == 0) {
                    if (e.NodeList) {
                        let zz = e.NodeList.map(es => {
                            if (es.NodeList) {
                                let res = es.NodeList.map(ess => {
                                    return ess.SelfScore ? ess.SelfScore : 0
                                })
                                return res.reduce((prev, cur, index, arr) => {
                                    return prev + cur
                                }, 0)
                            }
                        })
                        ff.sub = zz.reduce((prev, cur, index, arr) => {
                            return prev + cur
                        }, 0)
                    }
                } else {
                    if (e.NodeList) {
                        let zz = e.NodeList.map(es => {
                            if (es.NodeList) {
                                let res = es.NodeList.map(ess => {
                                    return ess.SelfScore ? ess.SelfScore : 0
                                })
                                return res.reduce((prev, cur, index, arr) => {
                                    return prev + cur
                                }, 0)
                            }
                        })
                        ff.add = zz.reduce((prev, cur, index, arr) => {
                            return prev + cur
                        }, 0)
                    }
                }

                return ff
            })
            let totala = 0
            let totals = 0


            params.listInfo.value.SelfTotalScore = params.lists.value[0].TotalScore


            for (let e of f) {
                if (e.add) {
                    totala += e.add
                } else if (e.sub) { totals += e.sub }
            }
            params.totala.value = totala
            params.totals.value = totals


        },
        handleDrop: (e) => {
            console.log(e, 'drag');
        },

        GetDepartmentConfig: (id) => {
            return new Promise((resolve,rej) => {

                Request({
                    url: "/Performance/GetDepartmentConfig",
                    method: 'post',
                    data: {
                        DepartmentId: id
                    }

                }).then(res => {


                    params.ScoreRate.value = res.Data.ScoreRate
                    resolve(1)

                })

            })
      


        },




        UpdateEvalutionUser: (id) => {
            return new Promise((resolve, rej) => {
                Request({
                    url: "performance/UpdateEvalutionUser",
                    method: 'post',
                    params: {
                        ItemId: id,
                    }
                }).then(res => {
                    resolve(1)
                    console.log(res, 'res')

                })
            })

        },
        GetOperateLogList: (id) => {
            return new Promise((resolve, rej) => {
                Request({
                    url: "performance/GetOperateLogList",
                    method: 'post',
                    params: {
                        FormId: id,
                    }
                }).then(res => {

                    params.logList.value = res.Data
                    resolve(1)
                })


            })

      

          
        },
    
    

        upload: (ti, i, is, iss) => {
            params.ti.value = ti
            params.i.value = i
            params.is.value = is
            params.iss.value = iss

            if (!params.lists.value[params.ti.value].NodeList
            [params.i.value].NodeList[params.is.value].NodeList
            [params.iss.value].ResultItemFileList) {
                params.lists.value[params.ti.value].NodeList
                [params.i.value].NodeList[params.is.value].NodeList
                [params.iss.value].ResultItemFileList = []
            }

        },
        Idealmark: (number, maxmark, flag = true) => {
            return dealmark(number,flag?maxmark:null)
        },


        handleCountModelConfirm: () => {
            params.autoSaveParams.value.countdown = params.autoSaveParams.value.ocountdown
            clearInterval(params.autoSaveParams.value.countdownTimer)
            clearInterval(params.autoSaveParams.value.mainTimer)
            params.autoSaveParams.value.countOpen = false

            methods.init()
            methods.onSubmit(0, false)
            methods.startMainTimer()
        },
        handleCountModelClose: () => {
            params.autoSaveParams.value.countdown = params.autoSaveParams.value.ocountdown
            clearInterval(params.autoSaveParams.value.countdownTimer)
            clearInterval(params.autoSaveParams.value.mainTimer)
            params.autoSaveParams.value.countOpen = false
            methods.startMainTimer()
        },
        startMainTimer: () => {
            params.autoSaveParams.value.mainTimer = setInterval(() => {
                params.autoSaveParams.value.countOpen = true
                params.autoSaveParams.value.countdownTimer = setInterval(() => {
                    params.autoSaveParams.value.countdown -= 1
                    if (params.autoSaveParams.value.countdown == 0) {

                        params.autoSaveParams.value.countdown = params.autoSaveParams.value.ocountdown
                        clearInterval(params.autoSaveParams.value.countdownTimer)
                        methods.init()
                        methods.onSubmit(0, false)
                        params.autoSaveParams.value.countOpen = false
                    }
                }, 1000)

            }, params.autoSaveParams.value.setIntervalTime)
        },


        mounted: () => {


        },

        init: () => {
            getBrowserInfo().catch(err => { console.log(err) })



            if (window.localStorage.getItem('pl')) {
                params.autoSaveParams.value.setIntervalTime = +window.localStorage.getItem('pl') * 1000 * 60
            } else {
                window.localStorage.setItem('pl', 5)
                params.autoSaveParams.value.setIntervalTime = 5 * 1000 * 60
            }

            if (window.localStorage.getItem('size')) {
                params.autoSaveParams.value.size = +window.localStorage.getItem('size')
            } else {
                window.localStorage.setItem('size', 26)
                params.autoSaveParams.value.size = 26
            }

            if (proxy) {
                params.proxy.value = proxy
            }
            const { message } = antd
            params.messageTest.value = message
            params.messageTest.value.config({
                top: `10vh`,
                duration: 7,
                maxCount: 1,
                rtl: true,
            });

            params.urlParams.value = queryURLParams()

            console.log(params.urlParams.value)

            //function queryURLParams() {
            //    const searchParams = window.location.search.substring(1).split("&");
            //    const params = {};

            //    for (const param of searchParams) {
            //        const [key, value] = param.split("=");
            //        params[key] = value;
            //    }

            //    return params;
            //}
            const { id } = queryURLParams()
            params.mid.value = id
      
            params.monthList.value = getMonthList()

            params.uploadLock.value = true

            let info = Storage.get('AccountInfo', true)
            Request({
                url: "/Account/createJwtToken",
                method: 'post',
                data: {
                    "userName": info && info.UserNo
                }
            }).then(res => {
                Storage.set('token', res.Data,true)
                let infos = Storage.get('AccountInfo', true)


                params.urlParams.value.did = infos.DepartmentId

                Request({
                    url: "/Performance/GetEvalutionResultDetail",
                    method: 'post',
                    params: {
                        FormId: params.urlParams.value.id
                    }
                }).then(async res => {

    
                    params.listInfo.value.DepartmentName = res.Data.DepartmentName
                    params.listInfo.value.UpdateTime = dealTime(res.Data.UpdateTime, 'YYYY-MM-DD HH:mm:ss')
                    params.listInfo.value.UserName = `${res.Data.UserName}(${res.Data.UserNo})`
                    params.listInfo.value.TotalScore = res.Data.TotalScore
                    params.listInfo.value.EvalutionUserList = res.Data.EvalutionUserList||"-"

                    params.listInfo.value.PlanNoticeName = res.Data.PlanNoticeName
                   await  methods.GetOperateLogList(params.urlParams.value.id)
                    let info = Storage.get('AccountInfo', true)

           
                        methods.GetDepartmentConfig(res.Data.DepartmentId).then(ress => {

                            if (ress) {

                                console.log(ress,'ress')
                            }


                            params.fileList.value = res.Data.FileList.map(e => {
                                return {
                                    ...e,
                                    name: e.FileName,
                                    url: e.url ? e.url : imageBaseUrl + e.FilePath.split('../..')[1],
                                    FileId: e.FileId
                                }
                            })

                            params.lists.value = res.Data.ItemList && res.Data.ItemList.map(e => {

                                return {
                                    ...e,
                                    totala: 0,
                                    totals: 0,
                                }
                            })
                            if (params.lists.value.length == 0) {
                                return
                            }

                            methods.ichange()

                            for (let i = 0; i < params.lists.value.length; i++) {
                                methods.iichange(i)
                            }

                        })


             
           

                
                   
                    params.uploadLock.value = false
              
                 
          

                    Request({
                        url: "/SystemConfig/GetUserListByDepartment",
                        method: 'post',
                        params: {
                            DepartmentId: res.Data.DepartmentId
                        }
                    }).then(res => {
                        params.memberGroup.value = res.Data.map(e => {
                            return {
                                label: `${e.UserName}(${e.UserNo})` ,
                                value: e.UserNo
                            }
                        })
                    })

             


                })





            })

            params.form.value.person = info.UserName
            params.form.value.subdept = info.DepartmentName




            let arry = ['责任', '目标', '风险', '隐患', '培训', '文化', '制度', '应急', '合规', '相关方']
            params.dataSource.value = arry.map(e => {
                return {
                    a: e,
                    b: "",
                    c: ""
                }
            })
 
            const { type } = queryURLParams()
            params.type.value = type

        },
        groupChange: (e) => {


            let item = params.checkGroup.value.find(es => es.value == e)


            params.cmemberGroup1.value = item.list.map(e => {

                return {
                    label: `${e.MemberName}(${e.UserNo})`,

                    value: e.UserNo
                }

            })

            params.s3Form.value.Time = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss')

            params.s3Form.value.checkMan = []

        },

        groupChange1: (e) => {

            let item = params.checkGroup.value.find(es => es.value == e)

            params.cmemberGroup2.value = item.list.map(e => {
                return {
                    label: `${e.MemberName}(${e.UserNo})`,
                    value: e.UserNo
                }
            })

            params.s4Form.value.Time = dayjs(Date.now()).format('YYYY-MM-DD HH:mm:ss')

            params.s4Form.value.checkMan = []

},
        onexport: () => {
            params.uploadLock.value = true
            html2canvas(document.querySelector("#alltable")).then(async (canvas) => {

                //proxy.$refs.test.appendChild(canvas)
                //params.uploadLock.value = false
                //return
                // 将 canvas 转换为 Blob
                const blob = await new Promise((resolve, reject) => {
                    canvas.toBlob(resolve, 'image/png');
                });

                // 创建 FormData 对象
                const formData = new FormData();
                formData.append('file', blob, 'pdf.png');

                Request({
                    url: "/download/uploadfile?Path=toPdf",
                    method: 'post',
                    data: formData
                }).then(res => {




                    Request({
                        url: `/Performance/ExportPdf?FileId=${res.Data[0].FileId}`,
                        method: 'post',

                    }).then(res => {


                        downloadfun('考评明细报表', res.Data)


                        params.uploadLock.value = false

                    })







                })
            });
        },
        onSubmit: (Status) => {




            for (let i = 0; i < params.lists.value.length; i++) {
                methods.iichange(i)
            }


            let obj = {
                FormId: params.mid.value,
                ActualTotalScore: params.listInfo.value.SelfTotalScore - params.totals.value + params.totala.value,
                TotalScore: params.totalAmount.value,
                IsSave: 0,
                Remark: params.checkFrom.value.advise
            }
            let models = [
                {
                    FormId: params.mid.value,
                    TypeId: 2,
                    TeamId: params.s3Form.value.group,
                    ApproverList: params.s3Form.value.checkMan && params.s3Form.value.checkMan.toString(),
                    EvaluationDate: params.s3Form.value.Time,
                    CooperatorList: params.s3Form.value.member && params.s3Form.value.member.toString(),
                    Score: params.lists.value.map(e => e.TotalScore)[1],
                    DepartmentManager: params.s3Form.value.duty
                },
                {
                    FormId: params.mid.value,
                    TypeId: 3,
                    TeamId: params.s4Form.value.group,
                    ApproverList: params.s4Form.value.checkMan && params.s4Form.value.checkMan.toString(),
                    EvaluationDate: params.s4Form.value.Time,
                    CooperatorList: params.s4Form.value.member && params.s4Form.value.member.toString(),
                    Score: params.lists.value.map(e => e.TotalScore)[2],
                    DepartmentManager: params.s4Form.value.duty
                }

            ]
            obj.models = models


            let ss = []
            for (let e of params.lists.value) {
                if (e.NodeList) {
                    e.NodeList.map(es => {
                        if (es.NodeList) {
                            es.NodeList.map(ess => {
                                if (ess.NodeList) {
                                    ess.NodeList.map(esss => {
                                        esss.ResultItemFileList = esss.uploadList ? esss.uploadList.filter(essss => essss.lastModified) : [],
                                        esss.ContentId = esss.Id
                                        ss.push(esss)
                                    })
                                }
                            })
                        }
                    })
                }

            }



   



            obj.items = ss

            /*     return*/
            Request({
                url: "/performance/AddEvaluationForm",
                method: 'post',
                data: obj
            }).then(res => {
                params.messageTest.value.success(res.Msg);
                setTimeout(() => {
                    methods.onBack()
                }, 1500)

            })





     

        },
        onBack: (test) => {
            window.close()
            //if (test) {
            //    return history.back()
            //}
            //window.location.href ='/Performance/PerformanceResultCheck'
        }


    }
    const template = {
        countModel: {
            template: `
            <a-modal v-model:open="autoSaveParams.countOpen" ok-text="立即保存" title="自动保存" v-on:cancel="handleCountModelClose" v-on:ok="handleCountModelConfirm">
                <div style='height:auto;font-size:14px'>
                    {{autoSaveParams.countdown}}秒后自动保存,如果您正在操作，请点击取消
                </div>

        </a-modal>
`,
            setup() {
                return {
                    ...params,
                    ...methods,
                };
            }
        },
        pdfPopModel: {
            template: `
           <a-modal v-model:open="pdfOpen" width = "80%" title = "PDF预览" v-on:ok="pdfOpen=false" >
<div style='height:700px'>
                <embed id="pdfviewscreen" :src="pdfurl" type="application/pdf" width="100%" style="height:100%;" />

</div>
  
            </a-modal >
`,
            setup() {
                return {
                    ...params,
                    ...methods,
                };
            }
        },
        bottomBtns: {
            template: `<div class="w-full bg-[#eeeeee] h-50  flex  items-center justify-end">
                    <a-space>
  <a-popconfirm
    title="确定执行此操作?"
    ok-text="确定"
    cancel-text="取消"
    @confirm="onSubmit(0)"
  >
       <a-button v-if="false" :loading="uploadLock" type="primary">保存</a-button>
  </a-popconfirm>


  <a-popconfirm
    title="确定执行此操作?"
    ok-text="确定"
    cancel-text="取消"
    @confirm="onSubmit(1)"
  >
         <a-button v-if="urlParams.status!=4&&urlParams.isEdit==1" :loading="uploadLock"  type="primary">同步</a-button>
  </a-popconfirm>

                        <a-button :loading="uploadLock"  v-on:click="onexport" type="primary">导出</a-button>
                        <a-button v-on:click="onBack(1)">返回</a-button>
                    </a-space>
                </div>`,
            setup() {

                return {
                    ...params,
                    ...methods,
                };
            }

        }
    }


    //let template = toRefs(vtemplate)
    return { // 返回对象给模板

        ...params,
        ...methods,
        template

    }
}


export default Composition